#{extends 'common/supervisor.html' /}
#{set title:'部门账单借款会员管理' /}

<div class="xn_c_contentwarp">
  <div class="xn_c_contentlist">
    #{include "supervisor/billCollectionManager/common/billCollectionManagerLeft.control"/}
    <div class="xn_c_content">
      <div class="xf_ht_tablelist">
        <!-- 搜索 -->
        #{form @deptLoanBidManager(), id:'deptLoanBidManager'}
        <input type="hidden" id="currPage" name="currPage"/>
        <input type="hidden" id="pageSize" name="pageSize"/>
        <input type="hidden" id="orderType" name="orderType" value="${page?.conditions?.order}"/>
        <div class="xf_ht_search">
          <div class="xf_ht_search_l">
            <span id="div_0" onClick="conditonSearch(0)">默认排序</span>
            <span id="div_1" onClick="conditonSearch(1)">借款金额<a id="div_a_1">↑</a></span>
            <span id="div_3" onClick="conditonSearch(3)">年利率 <a id="div_a_3">↑</a></span>
          </div>
        </div>
        <div class="xf_ht_search_inon">
          <div class="xf_ht_search_r">
            *{<div class="xf_ht_search_xl">
              <select id="select" name="type" class="xf_membill_selectAge">
                <option value="0">全部</option>
                <option value="1">正常</option>
                <option value="2">逾期</option>
                <option value="3">坏账</option>
              </select>
            </div>}*
            <div class="xf_ht_search_xl">
              <input id="textfield" name="keywords" type="text" class="search_w" title="请输入会员名" value="${page?.conditions?.keywords}"/>
            </div>
            <div class="xf_ht_search_xl">
              <span class="search_timesp">放款时间：</span>
              <input name="startDate" type="text" id="startDate" class="search_time" onclick="laydate()" style="cursor: pointer" value="${page?.conditions?.startDate}"/>
              <span class="search_timesp">--</span>
              <input name="endDate" type="text" id="endDate" class="search_time" onclick="laydate()" style="cursor: pointer"  value="${page?.conditions?.endDate}"/>
            </div>
            
            <div class="xf_ht_search_xl">
              <input type="submit" class="search_button" value="搜 索" />
            </div>
          </div>
        </div>
        #{/form}
        <!-- 列表内容 -->
        <div class="xn_c_content_top">
          #{table class:"xn_c_content_list",cellspacing:"0",cellpadding:"0",border:"0",tr_class_odd:"xn_tr_bj",width:"1300px"}
            #{tr}
              #{th}序号#{/th}
              #{th}借款标编号#{/th}
              #{th}借款人#{/th}
              #{th}信用等级#{/th}
              #{th}借款金额#{/th}
              #{th}借款标类型#{/th}
              #{th}年利率#{/th}
              #{th}借款期限#{/th}
              #{th}放款时间#{/th}
              #{th}本息合计#{/th}
              #{th}客服#{/th}
              #{th}操作#{/th}
            #{/tr}
            #{list page?.page}
            #{tr tr_index:_index}
              #{td}${(page?.currPage - 1)*page?.pageSize + _index}#{/td}
              #{td}${_?.bid_no}#{/td}
              #{td}${_?.user_name}#{/td}
              #{td}#{img src:"${_?.credit_level_image_filename}",alt:"",width:"25",height:"25"}#{/img}#{/td}
              #{td}${_?.amount.format("###,##0.00")}#{/td}
              #{td}#{img src:"${_?.small_image_filename}",alt:"",width:"25",height:"25"}#{/img}#{/td}
              #{td}${_?.apr}#{/td}
              #{td}
              ${_?.period}
              #{if _?.period_unit == -1}
              [年]
              #{/if}
              #{elseif _?.period_unit == 0}
              [月]
              #{/elseif}
              #{elseif _?.period_unit == 1}
              [日]
              #{/elseif}
              #{/td}
              #{td}${_?.audit_time?.format("yyyy-MM-dd")}#{/td}
              #{td}${_?.capital_interest_sum?.format("###,##0.00")}#{/td}
              #{td}${_?.supervisor_name}#{/td}
              #{td}
                <a class="xf_ta_onclick" href="@{bidDetail(_?.id, 19, 211)}" class="xf_ta_onclick">借款标详情</a>
                <span class="xf_ta_onclick" onclick="allocation('${_?.sign}',1);">分配</span>
              #{/td}
            #{/tr}
            #{/list}
          #{/table}
        </div>
        <!-- 列表底部 -->
        <div class="xn_c_content_bottom">
          <div class="page_warp">
            #{page currPage:page.currPage,totalCount:page.totalCount,pageSize:page.pageSize,theme:2,style:4/}
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!--借款标详情-弹出层 -->
<div id="detail" style="display:none;"></div>

<div id="kefucc" style="display:none;"></div>

<script type="text/javascript">

$(function(){  
  /* 高亮样式 */
  showHighLight(2, 2, 19);
    
  //条件查询控制样式
  var num= ${page.conditions?.order};
  
  if(num == 0){
    $("#div_0").addClass("xf_sea_isshow");
    return;
  }

  var sum = num/2;
  if(sum.toString().indexOf('.') == -1){
    var sum2 = num -1;
    $("#div_"+sum2).addClass("xf_sea_isshow");
    $("#div_a_"+sum2).html("↓");
    return;
  }

  $("#div_"+num).addClass("xf_sea_isshow");
  $("#div_a_"+num).html("↑");
});

function submit(){
  $("#loanUserManager").submit();
}

function showUserBidDetails(pageNum,pageSize,sign){
  var keywords = $("#keywords").val();
  var status = $("#status").val();
  $.ajax({
    url:"@{deptLoanUserBidDetail()}",
    type:"POST",
    data: {"pageNum" : pageNum, "pageSize" : pageSize,"sign" : sign,"keywords":keywords,"status" : status, "light" : 2},
    success:function(data){
      $("#detail").html(data);
      
      $.layer({
        type: 1,
        area: ['auto', 'auto'],
        title: '借款标详情',
        page: {dom : '#detail'}
      });
    },
    error:function(){alert("对不起，出现错误!");}
  })
}

function allocation(bidId,type){
  $.ajax({
    url : "@{supervisor.billCollectionManager.LoanUsers.queryAllSupervisors()}",
    type : "POST",
    data : {
      "currPage" : 1,
      "pageSize" : 5,
      "keyword"  :"",
      "bidId"    :  bidId,
      "type"     :type
    },
    success : function(data) {
      if (data.code < 0) {
        alert(data.msg);
        return;
      }
      
      $("#kefucc").html(data);
      
      $.layer({
        type: 1,
        area: ['60%', 'auto'],
        title: '分配',
        page: {dom : '#kefucc'}
      });
    },
    error : function() {
      alert(data.msg);
    }
  });
}

function conditonSearch(num){
	 var orderType= ${page?.conditions?.order};
	  if(orderType == 0){
	    $("#orderType").val(num);
	    $("#deptLoanBidManager").submit();
	    return;
	  }
	  var sum = orderType/2;
	  if(sum.toString().indexOf('.') == -1){
	    var sum2 = orderType - 1;
	    $("#orderType").val(num);
	    $("#deptLoanBidManager").submit();
	    return;
	  }else{
	    if(orderType == num){
	      $("#orderType").val(num + 1);
	      $("#deptLoanBidManager").submit();
	      return;
	    }else{
	      $("#orderType").val(num);
	      $("#deptLoanBidManager").submit();
	      return;
	    }
	  }
	}

function showPage(currPage, pageSize){
	  $("#currPage").val(currPage);
	  $("#pageSize").val(pageSize);
	  $("#deptLoanBidManager").submit();
	}
</script>
